Selecting Dynamic ID JQuery [migrated]

Posted by Vedran Wex Maricevic on Pro Webmasters See other posts from Pro Webmasters or by Vedran Wex Maricevic
Published on 2012-12-17T16:09:39Z Indexed on 2012/12/17 17:14 UTC
Read the original article Hit count: 235

Filed under:
|

I need to select dynamic id using JQuery, and once I select it then I need to do some action on it. This is the HTML that I have:

<input id="content_photos_attributes_1355755712119_image"   name="content[photos_attributes][1355755712119][image]" size="30" type="file">

Please note the id value, text is always the same however the number changes (I do not have control over that change).

What I need to do is to create on click for that element. This is what I got so far, and it is not working.

<script type="text/javascript">
jQuery.noConflict();

  jQuery("input[id *= 'content_photos_attributes_']").click(function() {

  alert("Image deletion is clicked");
});
</script>

It really makes no difference whether I select that element by ID or by its name.

© Pro Webmasters or respective owner

Related posts about html

Related posts about jQuery